/* 
 * File:   Psi.h
 * Author: mori
 *
 * Created on April 28, 2011, 12:42 PM
 */
#include "Coils.h"
#include "Grid.h"
#ifndef PSI_H
#define	PSI_H



extern float** psipl_1;
extern float** psipl_m;
extern float** psipl_tmp;


extern float** psipl_s;
extern float** psipl_rs;
extern float** psipl_on_g_s;
extern float** psitotal_s;

extern float** psist;
extern float** psitotal_1;
extern float** psitotal_m;
extern float** psitotal_tmp;
extern float** psipl_on_g;

class Psi{
    public: Psi(Grid* grid, Coils* coils);
            ~Psi();

            float   st_point(float r, float z);
            float   get_psist_point(int i,  int j) {return psist[i][j];}
            float** st_grid();

            float   pl_point(float r, float z, float** j_phi);

            float   get_psipl_point(int i, int j) {return psipl_m[i][j];}
            float** pl_grid(float** j_phi, float** psipl);

            float   total_point(float psi_pl, float psi_st);
            float   get_psi_point(int i, int j) {return psitotal_m[i][j];}
            float** total_grid(float** psi_pl, float** psi_st, float** psisum);

            void    bound(float** psi_grid);

            float** get_psipl_on_g(float** jphi);

            float   get_psipl_on_g_point(int i, int j) {return psitotal_m[i][j];}
            float   H(float psi_);
            float   F(float psipl);
            float   F(int i, int j);
            int get_i(int q) {return q/(m+1);}//
            int get_j(int q) {return (q - get_i(q)*(m+1) ); }
	    int get_q(int i, int j) {return i*(m+1) +j;}


    public:
    int num_r;
    int num_z;
    float left_r;
    float right_r;
    float up_z;
    float down_z;

    int left_r_g, right_r_g, up_z_g, down_z_g; // plasma area indexes

    float h_r;
    float h_z;
    float delta_s;
    float psi_g;
    int num_coil;
    int m, n;

    Coils* its_coils;
    Grid* its_grid;
};
#endif	/* PSI_H */

